<template>
  <div>
    用户名 <input type="text" v-model="username">
    密码 <input type="password" v-model="password">
    <a-button @click="login">登录</a-button>
    <a-button @click="dingding" >钉钉</a-button>
    <a-button @click="git">Gitee</a-button>
  </div>
</template>

<script>
  import axios from 'axios'

  export default {
    name: "login",
    data() {
      return {
        username:'',
        password:''
      }
    },
    methods: {
      login() {
        axios.post(
          'http://127.0.0.1:8000/login/',
          {username:this.username,password:this.password}
        ).then(res => {
          console.log(res.data)
          if(res.data.code===200){
            alert('登录成功')
            sessionStorage.setItem('username',this.username)
            sessionStorage.setItem('uid',res.data.uid)
            this.$router.push('/')
          }

        })
        
      },
      //钉钉登录
			dingding:function(){

				window.location.href = "http://localhost:8000/ding/";

			},
      //钉钉登录
			git:function(){

				window.location.href = "http://localhost:8000/gitee/";

			},
    }
  }
</script>

